<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>v-on</title>
</head>
<body>
    <div id="app">
        <input type="button" value="单击事件" v-on:click="doIt(10,'来了啊')">
        <input type="button" value="双击事件" @dblclick="doIt(10,'来了啊')">
        <input type="text" @keyup.enter="sayHi"><!-- keyup按键松开事件，enter回车键，即按下回车键触发sayHi函数 -->
        <h2 @click="changFood">{{food}}</h2>    
    </div>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script>
        var app=new Vue({
            el:"#app",
            data:{
                food:"食物"
            },
            methods:{
                doIt:function(p1,p2){
                    alert("绑定事件"+p1+p2);
                },
                changFood:function(){
                    this.food+="很美味";//this调用本对象的food
                },
                sayHi:function(){
                    alert("hello")
                }
            },
        })
    </script>
</body>
</html>